package veterinaria.servlet.cliente;

import java.io.IOException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import veterinaria.excepcion.DAOExcepcion;
import veterinaria.negocio.GestionAdministrarClientes;


/**
 * Servlet implementation class ClienteCambiarServlet
 */
@WebServlet("/ClienteCambiarServlet")
public class ClienteCambiarServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ClienteCambiarServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	/*	vo.setIdCliente(idCliente);
		vo.setDsNombre(dsNombre);
		vo.setDsApellido(dsApellido);
		vo.setDsCorreo(dsCorreo);
		vo.setDsDireccion(dsDireccion);
		vo.setNuTeleFijo(nuTeleFijo);
		vo.setNuTeleMovil(nuTeleMovil);
		vo.setFlCliente(flCliente);
		vo.setNuRuc(nuRuc);
		vo.setDsImagenCliente(dsImagenCliente);
		vo.setDsNotasCliente(dsNotasCliente);
		vo.setStActivo(stActivo);*/
		
		int a = Integer.parseInt(request.getParameter("idCliente"));
		String b = request.getParameter("nombre");
		String c = request.getParameter("apellido");
		String d = request.getParameter("correo");
		String f = request.getParameter("direccion");
		String g = request.getParameter("fonocasa");
		String h = request.getParameter("celular");
		boolean i = Boolean.parseBoolean(request.getParameter("condicion"));
		String j = request.getParameter("ruc");
		String k = request.getParameter("imagen");
		String l = request.getParameter("notas");
		String m = request.getParameter("estado");
		GestionAdministrarClientes negocio = new GestionAdministrarClientes();
				try {
					negocio.actualizar(a, b, c, d, f, g, h, i, j, k, l, "1");
					response.sendRedirect(request.getContextPath()	+ "/confActCliente.jsp");
					//response.sendRedirect(request.getContextPath()	+ "/ClienteBuscarServlet?nombre=&cbofiltro=3");
				} catch (DAOExcepcion e) {
					System.out.println(e.getMessage());
					RequestDispatcher rd = request.getRequestDispatcher("error.jsp");
					rd.forward(request, response);
				}
	
	}
}
